/*
============================================================================
Name        : dd_define.h
Author      : Jian (raphyer@hotmail.com)
Version     :
Copyright   : GPL
Description : dd_define.h - header file
============================================================================
*/

#ifndef DD_DEFINE_H
#define DD_DEFINE_H


/* -------- platform macro -------- */

// #define __DD_WINDOWS
// #define __DD_LINUX
#define __DD_SYMBIAN
// #define __DD_MTK


#define __DD_DEBUG

#define __DD_LUA_SUPPORT 

#define __DD_PERFORMANCE_CHECK

#define __DD_UNITTEST

#ifdef __DD_UNITTEST
#define __DD_PERFORMANCE_CHECK
#endif


/* extern "C" {} define */
#ifdef  __cplusplus
#define __DD_BEGIN_DECLS  extern "C" {
#define __DD_END_DECLS    }
#else
#define __DD_BEGIN_DECLS
#define __DD_END_DECLS
#endif

/*
* Base type definition 
*/

#define DD_NULL		0
#define DD_CHAR		char
#define DD_UINT8    unsigned char
#define DD_UTF8		unsigned char
#define DD_UNICODE  unsigned short 
#define DD_INT		int 
#define DD_UINT		unsigned int 
#define DD_DOUBLE   double
#define DD_FLOAT    float

#define DD_BOOL		int 
#define DD_TRUE		1
#define DD_FALSE	0


#ifdef __DD_WINDOWS

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <time.h>

/* For VS2003 disable some warnings */
#pragma warning (disable : 4311)
#pragma warning (disable : 4312)


#define DD_MALLOC		dd_malloc
#define DD_FREE			dd_free
#define DD_MEMSET		memset
#define DD_MEMMOVE		memmove
#define DD_MEMCPY		memcpy
#define DD_MEMCMP       memcmp
#define DD_SRAND		srand
#define DD_RAND			rand
#define DD_TIME			time
#define DD_STRLEN(s)    strlen((const char*)(s))
#define DD_STRCMP       strcmp
#define DD_STRCPY       strcpy
#define DD_STRNCPY      strncpy
#define DD_STRCAT       strcat
#define DD_STRNCAT      strncat
#define DD_STRSTR       strstr

#define DD_LOG          printf

#define __dd_inline__	

#endif	/* WIN32 */

#ifdef __DD_SYMBIAN

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys\time.h>

#define DD_MALLOC		dd_malloc
#define DD_FREE			dd_free
#define DD_MEMSET		memset
#define DD_MEMMOVE		memmove
#define DD_MEMCPY		memcpy
#define DD_MEMCMP       memcmp
#define DD_SRAND		srand
#define DD_RAND			rand
#define DD_TIME			time
#define DD_STRLEN(s)    strlen((const char*)(s))
#define DD_STRCMP       strcmp
#define DD_STRCPY       strcpy
#define DD_STRNCPY      strncpy
#define DD_STRCAT       strcat
#define DD_STRNCAT      strncat
#define DD_STRSTR       strstr

#define DD_LOG          dd_log

#define __dd_inline__	

#endif	/* __DD_SYMBIAN */


/* Common include */
__DD_BEGIN_DECLS
#include "dd_log.h"
#include "dd_printf.h"
#include "dd_memory.h"
__DD_END_DECLS



#define DD_MAX_FLIE_LEN  256 


#define __do_destroy(d)   do {if(d) DD_FREE(d); (d) = NULL;} while (0) 

#define DD_MIN(a,b)		((a)<(b)?(a):(b)) 
#define DD_MAX(a,b)		((a)>(b)?(a):(b)) 


#ifdef __DD_DEBUG
#define __Log_File_Line		{ DD_LOG("Assert in file = %s and line = %d", __FILE__, __LINE__); }
#define __Panic_File_Line	{ } 
#else 
#define __Log_File_Line		{ }
#define __Panic_File_Line	{ }
#endif	

#define __DD_ASSERT(c)              do { if(!((c))) { __Log_File_Line; __Panic_File_Line; } } while(0)
#define __DD_ASSERT_DEFENSE(c,d)    do { if(!((c))) { __Log_File_Line; __Panic_File_Line; {d;}; } } while(0)


#define __DD_CHECK_PTR(p, t, d)     __DD_ASSERT_DEFENSE((p) && ((((DD_UINT)(p)) % sizeof(t)) == 0), d)


#endif	/* DD_DEFINE_H */

/* End of File */
